home *** CD-ROM | disk | FTP | other *** search
- Path: news.accent.net!news
- From: sgirouard@accent.net (Simon Girouard)
- Newsgroups: comp.lang.c
- Subject: Copy Binary files to printer
- Date: 19 Apr 1996 02:02:06 GMT
- Organization: Accent Internet
- Message-ID: <4l6s6u$3cg@news.accent.net>
- NNTP-Posting-Host: 205.205.162.110
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- Hi there!
-
- I am writing a C program that simulate the DOS "COPY /B" command but send
- the file to a printer on a parallel port.
-
- Here is the code I wrote :
-
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #define BUFSIZE 512
-
- main()
- {
- FILE *in, *pfd;
- register i, test;
- char buf[BUFSIZE];
-
- if ((pfd = fopen("lpt1", "wb")) == NULL)
- exit(errno);
-
- if ((in = fopen("d:\\tmp\\test.tst", "rb")) == NULL)
- exit(errno);
-
- do {
- if ((i = fread(buf, 1, BUFSIZE, in)) == -1)
- exit(errno);
-
- if ((test = fwrite(buf, 1, i, pfd)) == -1)
- exit(errno);
-
- } while (i == BUFSIZE);
-
- fclose(in);
- fclose(pfd);
-
- return 0;
- }
-
-
- The problem is that when writing to a file, it works fine but
- when writing to the parrallele port "LPT1" it seems to have trouble
- with the handshake and some garbage gets printed.
-
- Is there a way to fix this !
-
- Simon G.
-
-